<?php
    $count     = 0;
    $sub_total = 0;
?>

<p style="max-height:30px!important;overflow:hidden;">
    <a target="_blank" href="<?php echo page_url(); ?>" title="<?php echo SITE_NAME; ?>">
        <img width="172px" alt="<?php echo SITE_NAME; ?>" src="cid:logo" />
    </a>
</p>
<h3 style="margin-top:30px;">ĐƠN ĐẶT HÀNG</h3>
<p style="background: #F0F0E9;padding:5px;font-weight: bold;text-transform: uppercase;text-align: center;">Thông tin đặt hàng</p>
<table style="width:100%;border-collapse:collapse">
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;width: 150px;">Người đặt hàng :</th><td><?php echo $options['name']; ?></td></tr>
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Thời gian đặt hàng :</th><td><?php echo fdate_format($options['created_at'], 'd/m/Y H:i:s'); ?></td></tr>
    <tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Email :</th><td><?php echo $options['email']; ?></td></tr>
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Số điện thoại :</th><td><?php echo $options['phone']; ?></td></tr>
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Địa chỉ :</th><td><?php echo $options['address']; ?></td></tr>
    <tr><th style="text-align:left;padding:5px;">Ghi chú :</th><td><?php echo $options['note']; ?></td></tr>
</table>
<p style="background: #F0F0E9;padding:5px;font-weight: bold;text-transform: uppercase;text-align: center;">Thông tin nhận hàng</p>
<table style="width:100%;border-collapse:collapse">
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;width: 150px;">Người nhận hàng :</th><td><?php echo $options['receiver_name']!=''?$options['receiver_name']:$options['name']; ?></td></tr>
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Email :</th><td><?php echo $options['receiver_email']!=''?$options['receiver_email']:$options['email']; ?></td></tr>
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Số điện thoại :</th><td><?php echo $options['receiver_phone']!=''?$options['receiver_phone']:$options['phone']; ?></td></tr>
	<tr style="border-bottom:1px solid #F7F7F0;"><th style="text-align:left;padding:5px;">Địa chỉ :</th><td><?php echo $options['receiver_address']!=''?$options['receiver_address']:$options['address']; ?></td></tr>
</table>
<p style="background: #F0F0E9;padding:5px;font-weight: bold;text-transform: uppercase;text-align: center;">Chi tiết đơn hàng</p>
<table style="width:100%;border-collapse:collapse">
	<thead>
		<tr style="background:#FE980F;">
            <td>&nbsp;</td>
			<td style="padding:5px;text-align: center;vertical-align: middle;text-transform:uppercase;font-weight:bold;color:#FFF">Sản phẩm</td>
			<td style="padding:5px;text-align: center;vertical-align: middle;text-transform:uppercase;font-weight:bold;color:#FFF">Đơn giá</td>
			<td style="padding:5px;text-align: center;vertical-align: middle;text-transform:uppercase;font-weight:bold;color:#FFF">Số lượng</td>
			<td style="padding:5px;text-align: center;vertical-align: middle;text-transform:uppercase;font-weight:bold;color:#FFF">Thành tiền</td>
		</tr>
	</thead>
	<tbody>
        <?php foreach($cart as $index=>$item){ ?>
		<tr style="border-bottom: 1px solid #F7F7F0">
			<td style="vertical-align:middle;">
				<a href="<?php echo product_url($item['options']['slug']); ?>">
					<img width="96px" src="cid:<?php echo $index; ?>" alt="<?php echo $item['options']['shop_title']; ?>" title="<?php echo $item['options']['shop_title']; ?>"/>
				</a>
			</td>
			<td>
				<h4>
                    <a href="<?php echo product_url($item['options']['slug'], $item['options']['code']); ?>" style="text-decoration: none;text-transform: uppercase;color: #363432;font-weight: normal;">
                        <?php echo $item['name']; ?>
                    </a>
                </h4>
				<p>Mã sp: <?php echo $item['options']['code']; ?></p>
				<p>
					<a href="<?php echo shop_url($item['options']['shop_slug']); ?>" style="color: #428bca;text-decoration: none;text-transform: uppercase;">
                        <?php echo $item['options']['shop_title']; ?>
                    </a>
				</p>
			</td>
			<td style="color: #696763;font-size: 18px;text-align:center;"><?php echo currency_format($item['price']); ?></td>
			<td style="color: #696763;font-size: 16px;text-align:center;font-weight:bold;"><?php echo $item['qty']; ?></td>
			<td style="color: #FE980F;font-size: 18px;text-align:center;"><?php echo currency_format($item['subtotal']); ?></td>
            <?php
                $count += 1;
                $sub_total += $item['subtotal'];
            ?>
		</tr>
		<?php } ?>
		<tr style="background: #fe980f;color: #FFF">
			<td colspan="4">&nbsp;</td>
			<td colspan="2">
				<p style="margin:5px 0px;text-transform: uppercase;font-weight: bold;letter-spacing: 1px;">Tổng số sản phẩm : <?php echo $count; ?></p>
				<hr style="border: none;background: #FFF;border-top: 1px solid #FFF;" />
				<p style="margin:5px 0px;text-transform: uppercase;font-weight: bold;letter-spacing: 1px;">Tổng giá trị : <?php echo currency_format($sub_total); ?></p>
			</td>
		</tr>
	</tbody>
</table>